<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<meta http-equiv="cache-control" content="no-cache" />
		<meta http-equiv="expires" content="0" />
		<meta name="viewport"
			content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" />
		<meta name="apple-mobile-web-app-capable" content="yes" />
		<meta name="apple-mobile-web-app-status-bar-style" content="white" />
		<meta name="format-detection" content="telephone=no" />
		<!--Iphpone电话号码串识别 -->
		<meta http-equiv="x-rim-auto-match" content="none" />
		<!--电话号码串识别 -->
		<title>拨云见日科技</title>
		<link rel="SHORTCUT ICON" href="/static/favicon.ico" type="image/x-icon"/>
		<script src='/static/js/jquery.js' type='text/javascript'></script>
		<script src='/static/js/qrcode.js' type='text/javascript'></script>
		<script src='/static/js/layui.js' type='text/javascript'></script>
		<script src='/static/js/common.js' type='text/javascript'></script>
		<link href="/static/css/index.css" rel="stylesheet" type="text/css" />
		<link href="/static/css/layui.css" rel="stylesheet" type="text/css" />
	</head>
	<body>
		<!--头部-->
		{% include "base.html" %}
		<div class="wrapper">
			<div style='position: fixed; right:10px;bottom:10px;text-align:center;'>
				<ul id="plcFun">

				</ul>
			</div>
			<div class="wrapper_cont" style="width:90%">
				<div class="layui-card-body">
					<div class='layui-panel' style="height:70%;width:98%;padding:0 5px">
						{% if data == '2' %}
							{% include "info_cgrk.html" %}
						{% endif %}
						{% if data == '3' %}
							{% include "info_scjg.html" %}
						{% endif %}
					</div>
				</div>
				<div class="layui-card-body" style="border-top:1px solid #000000;width:100%">
					<div class="layui-row layui-col-space15" id="comFun">

				  	</div>
				</div>
			</div>
		</div>
	</body>
	<script type='text/javascript'>
			var param = "{{data}}"
			var robotid = ""
			$(function(){
				document.getElementById("v").value="";
				getRobot();
			})
			function getRobot(){
				var action = $("#mm").attr("action")
				var sql = "select ri.id,ri.robot_id,ri.robot_ip,rc.class_name from byjr_robot_info ri INNER JOIN byjr_robot_classify rc on ri.robot_class=rc.id"+
							" where ri.robot_id = '"+param+"'";
				$.post(action,{sql:sql},function(result){
					result = JSON.parse(result);
					if(!result||result.length==0){
						layer.msg("无效机器人")
						return;
					}
					$("#robot_id").html(result[0][1]);
					$("#robot_ip").html(result[0][2]);
					$("#robot_class").html(result[0][3]);
					robotid = result[0][0]
   					loadData2();
        			loadData();
					initData()
					getValue();
				});
			}

			function getValue(){
                v = document.getElementById('v').value;
                if(!v){
                	$("#v").focus();
                    setTimeout(getValue,1000);
                    return;
                }
                if(v=='WRBD'){
					document.getElementById('v').value = "";
					setTimeout(function(){
						location.href = "form.html?data="+param
					},1000);
				}

				select(v)

                document.getElementById('v').value = "";
                setTimeout(getValue,1000);
            }

			function loadData(){
				var action = $("#mm").attr("action")
				var sql = "select ra.ability_qrcode,ra.ability_name from byjr_robot_info ri INNER JOIN byjr_robot_ability_rel rar on ri.id = rar.robot_id " +
						"INNER join byjr_robot_ability ra on rar.ability_id = ra.id where ri.robot_id = '"+param+"' order by ra.sort asc ";
				$.post(action,{sql:sql},function(result){
					result = JSON.parse(result);
					for(v in result){
						id = "li_"+result[v][0];
						$("#plcFun").append("<li id='"+id+"' style='font-size: 10px;padding-top:3px'>"+result[v][1]+"</li>");
					}

					for(v in result){
						var id = "li_"+result[v][0]
						new QRCode(document.getElementById(id), {
							text: result[v][0],
							colorDark: '#000000',
							colorLight: '#ffffff',
							width:100,
							height:100,
							correctLevel: QRCode.CorrectLevel.H
						});
					}
				});
			}

			function loadData2(){
				var action = $("#mm").attr("action")
				var sql = "select ra.ability_qrcode,ra.ability_name from byjr_robot_info ri " +
						" INNER JOIN byjr_robot_classify rc on ri.robot_class = rc.id " +
						" INNER JOIN byjr_robot_classify_ability_rel rcr on rc.id = rcr.classify_id " +
						" INNER JOIN byjr_robot_ability ra on rcr.ability_id = ra.id " +
						" where ri.id = "+param+" order by ra.sort asc ";
				$.post(action,{sql:sql},function(result){
					result = JSON.parse(result);
					for(v in result){
						id = "cli_"+result[v][0];
						$("#comFun").append("<div class='layui-panel barcode'><div id='"+id+"'></div>"+result[v][1]+"</div>");
					}

					for(v in result){
						var id = "cli_"+result[v][0]
						new QRCode(document.getElementById(id), {
							text: result[v][0],
							colorDark: '#000000',
							colorLight: '#ffffff',
							width:150,
							height:150,
							correctLevel: QRCode.CorrectLevel.H
						});
					}
				});
			}
		</script>
	</html>
